import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '项目',
    align:"center",
    dataIndex: 'projectId_dictText'
   },
   {
    title: '工作类型',
    align:"center",
    dataIndex: 'workDayType_dictText'
   },
   {
    title: '填写人',
    align:"center",
    dataIndex: 'dailyOwner'
   },
   {
    title: '今日工作事项',
    align:"center",
    dataIndex: 'dailyWorkContent'
   },
   {
    title: '明日工作计划',
    align:"center",
    dataIndex: 'tomorrowWorkPlan'
   },
   {
    title: '工作开始时间',
    align:"center",
    sorter: true,
    dataIndex: 'dailyStartDate'
   },
   {
    title: '工作结束时间',
    align:"center",
    sorter: true,
    dataIndex: 'dailyEndDate'
   },
   {
    title: '是否有风险',
    align:"center",
    sorter: true,
    dataIndex: 'isRisk_dictText'
   },
   {
    title: '风险内容',
    align:"center",
    dataIndex: 'riskContent'
   },
   {
    title: '创建人',
    align:"center",
    dataIndex: 'createBy'
   },
   {
    title: '创建日期',
    align:"center",
    sorter: true,
    dataIndex: 'createTime'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "工作类型",
      field: "workDayType",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"work_day_type"
      },
      //colProps: {span: 6},
 	},
	{
      label: "填写人",
      field: "dailyOwner",
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "工作开始时间",
      field: "dailyStartDate",
      component: 'DatePicker',
      componentProps: {
         showTime:true,
         valueFormat: 'YYYY-MM-DD HH:mm:ss'
       },
      //colProps: {span: 6},
 	},
	{
      label: "工作结束时间",
      field: "dailyEndDate",
      component: 'DatePicker',
      componentProps: {
         showTime:true,
         valueFormat: 'YYYY-MM-DD HH:mm:ss'
       },
      //colProps: {span: 6},
 	},
	{
      label: "是否有风险",
      field: "isRisk",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"yes_or_no"
      },
      //colProps: {span: 6},
 	},
	{
      label: "创建日期",
      field: "createTime",
      component: 'DatePicker',
      componentProps: {
         showTime:true,
         valueFormat: 'YYYY-MM-DD HH:mm:ss'
       },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '项目',
    field: 'projectId',
    component: 'JSearchSelect',
    componentProps:{
       dict:"tm_project,project_name,id"
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入项目!'},
          ];
     },
  },
  {
    label: '工作类型',
    field: 'workDayType',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"work_day_type"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入工作类型!'},
          ];
     },
  },
  {
    label: '今日工作事项',
    field: 'dailyWorkContent',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入今日工作事项!'},
          ];
     },
  },
  {
    label: '明日工作计划',
    field: 'tomorrowWorkPlan',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入明日工作计划!'},
          ];
     },
  },
  {
    label: '工作开始时间',
    field: 'dailyStartDate',
    component: 'DatePicker',
    componentProps: {
       showTime:true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入工作开始时间!'},
          ];
     },
  },
  {
    label: '工作结束时间',
    field: 'dailyEndDate',
    component: 'DatePicker',
    componentProps: {
       showTime:true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入工作结束时间!'},
          ];
     },
  },
  {
    label: '是否有风险',
    field: 'isRisk',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"yes_or_no"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入是否有风险!'},
          ];
     },
  },
  {
    label: '风险内容',
    field: 'riskContent',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入风险内容!'},
          ];
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表表格配置
export const dailyItemColumns: JVxeColumn[] = [
    {
      title: '批次',
      key: 'batchId',
      type: JVxeTypes.selectSearch,
      dictCode:"tm_project_batch,batch_name,id",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '系统',
      key: 'systemId',
      type: JVxeTypes.selectSearch,
      dictCode:"tm_project_system,system_name,id",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '测试阶段',
      key: 'testStageId',
      type: JVxeTypes.selectSearch,
      dictCode:"tm_test_stage,test_stage_name,id",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '工作内容',
      key: 'workContent',
      type: JVxeTypes.selectSearch,
      dictCode:"tm_daily_work_type,daliy_type,id",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '数量',
      key: 'workItemNumbers',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '风险',
      key: 'riskContent',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '备注',
      key: 'comments',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  ]

// 高级查询数据
export const superQuerySchema = {
  projectId: {title: '项目',order: 0,view: 'sel_search', type: 'string',dictTable: 'tm_project', dictCode: 'id', dictText: 'project_name',},
  workDayType: {title: '工作类型',order: 1,view: 'list', type: 'string',dictCode: 'work_day_type',},
  dailyOwner: {title: '填写人',order: 2,view: 'text', type: 'string',},
  dailyWorkContent: {title: '今日工作事项',order: 3,view: 'textarea', type: 'string',},
  tomorrowWorkPlan: {title: '明日工作计划',order: 4,view: 'textarea', type: 'string',},
  dailyStartDate: {title: '工作开始时间',order: 5,view: 'datetime', type: 'string',},
  dailyEndDate: {title: '工作结束时间',order: 6,view: 'datetime', type: 'string',},
  isRisk: {title: '是否有风险',order: 7,view: 'list', type: 'string',dictCode: 'yes_or_no',},
  riskContent: {title: '风险内容',order: 8,view: 'textarea', type: 'string',},
  createBy: {title: '创建人',order: 9,view: 'text', type: 'string',},
  createTime: {title: '创建日期',order: 10,view: 'datetime', type: 'string',},
  //子表高级查询
  dailyItem: {
    title: '日报内容',
    view: 'table',
    fields: {
        batchId: {title: '批次',order: 0,view: 'sel_search', type: 'string',dictTable: 'tm_project_batch', dictCode: 'id', dictText: 'batch_name',},
        systemId: {title: '系统',order: 1,view: 'sel_search', type: 'string',dictTable: 'tm_project_system', dictCode: 'id', dictText: 'system_name',},
        testStageId: {title: '测试阶段',order: 2,view: 'sel_search', type: 'string',dictTable: 'tm_test_stage', dictCode: 'id', dictText: 'test_stage_name',},
        workContent: {title: '工作内容',order: 3,view: 'sel_search', type: 'string',dictTable: 'tm_daily_work_type', dictCode: 'id', dictText: 'daliy_type',},
        workItemNumbers: {title: '数量',order: 4,view: 'number', type: 'number',},
        riskContent: {title: '风险',order: 5,view: 'text', type: 'string',},
        comments: {title: '备注',order: 6,view: 'text', type: 'string',},
    }
  },
};
